package com.example.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description : TODO
 * @Author : ZYX
 * @Date : 2022/4/29 15:51
 * @Version : 1.0
 **/
public class ThreadLocalTest {

    public static void main(String[] args) {

        try {
            ExecutorService executorService = Executors.newFixedThreadPool(45);
            for (int i = 0; i < 45; i++) {
                executorService.submit(new Runnable() {
                    @Override
                    public void run() {
                        byte[] bytes = new byte[1024 * 1024];
                    }
                });
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        ThreadLocal<byte[]> objectThreadLocal = new ThreadLocal<>();
        objectThreadLocal.set(new byte[1024*1024]);

        System.gc();
        System.out.println("gc结束");
        byte[] bytes = new byte[1024*1024* 10];
        System.out.println("结束");
    }

}
